#pragma once
#include <memory>

#ifdef __cplusplus
extern "C" {
#endif
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libswscale/swscale.h"
#ifdef __cplusplus
}
#endif

#include <queue>
#include <mutex>
#include <functional>

namespace Media{
    class MjpegDecode{
    public:
        using Ptr = std::shared_ptr<MjpegDecode>;
        using NV12FrameCallBack = std::function<void (uint8_t*, int,  int, int, int)>;
        MjpegDecode(NV12FrameCallBack frameBack);
        ~MjpegDecode();
        void PushMjpegFrame(uint8_t *data, int size);
    private:
        bool init();
        AVCodecContext* m_codec_ctx;
        NV12FrameCallBack  m_frameBack;
    };
}